#include <stdio.h>

unsigned long int next = 1;

int rand(void);
void srand(unsigned int seed);

int main()
{
    int i;

    i = 0;
    while (i < 10)
    {
        srand(next);
        printf("rand=%d\n", rand());

        ++i;
    }

    return 0;
}

int rand(void)
{
    next = next * 1103512545 + 12345;
    return (unsigned int)(next / 65536) % 32768;
}

void srand(unsigned int seed)
{
    next = seed;
}
